


import 'package:bike_ride/api/common_repository.dart';
import 'package:bike_ride/common/mvvm/base_view_model.dart';
import 'package:bike_ride/common/widget/notifier_widget.dart';
import 'package:bike_ride/model/wallet/model/recharge_arrow_m.dart';
import 'package:bike_ride/model/wallet/view/lately_recharge_v.dart';
import 'package:bike_ride/model/mine/model/finance_stat_m.dart';
import 'package:dio/dio.dart';

class LatelyRechargeViewModel extends PageViewModel<LatelyRechargeViewState> {
  CancelToken? cancelToken;

  DiscountStatM? discountStatM;
  List<RechargeArrowM> rechargeArrowMList = [];

  @override
  onCreate() {
    cancelToken = CancelToken();
    pageDataModel = PageDataModel();
    getFinanceInfo();
    getRechargeArrowList();
  }

  @override
  onDispose() {
    if (!(cancelToken?.isCancelled ?? true)) {
      cancelToken?.cancel();
    }
    super.onDispose();
  }

  Future getFinanceInfo() async {
    final result = await CommonRepository.getFinanceInfoIdl(cancelToken: cancelToken);
    discountStatM = result;
    state.notifyChange();
  }

  Future getRechargeArrowList() async {
    final result = await CommonRepository.getRechargeArrowListIdl(cancelToken: cancelToken);
    rechargeArrowMList = result;
    state.notifyChange();
  }


  /// 请求数据
  @override
  Future<PageViewModel?> requestData({Map<String, dynamic>? params}) async {
    return null;

  }
}